//
//  SeparatePlanCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/15.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "SeparatePlanCell.h"

@implementation SeparatePlanCell

#pragma mark - lifecycle methods

- (void)setupUI{
    
    self.backgroundColor = KWhiteColor;
    
    [self.contentView addSubview:self.shopIcon];
    [self.contentView addSubview:self.pigTypeTipLab];
    [self.contentView addSubview:self.pigTypeNOLab];
    [self.contentView addSubview:self.pigTypePriceLab];
    [self.contentView addSubview:self.pigTypePriceCancelLab];
    [self.contentView addSubview:self.pigTypeWeightLab];
    [self.contentView addSubview:self.pigTypePriceSignalLab];

}

- (void)setupLayout
{
    [self.shopIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
        make.width.height.mas_equalTo(68);
    }];
    
    [self.pigTypeTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.shopIcon.mas_right).mas_offset(13);
        make.top.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(22);
    }];
    
    [self.pigTypeNOLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.pigTypeTipLab.mas_right).mas_offset(4);
        make.top.mas_equalTo(15);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(20);
    }];
    
    [self.pigTypePriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.shopIcon.mas_right).mas_offset(13);
        make.top.mas_equalTo(self.pigTypeTipLab.mas_bottom).mas_offset(29);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
    }];
    
    [self.pigTypePriceCancelLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.pigTypePriceLab.mas_right).mas_offset(5);
        make.top.mas_equalTo(self.pigTypePriceLab.mas_top);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(20);
    }];
    
    
    {
        [self.pigTypeWeightLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.shopIcon.mas_right).mas_offset(13);
            make.top.mas_equalTo(self.pigTypeTipLab.mas_bottom).mas_offset(7);
            make.width.mas_equalTo(66);
            make.height.mas_equalTo(16);
        }];
    }
    
    
    {
        [self.pigTypePriceSignalLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.pigTypeWeightLab.mas_right).mas_offset(5);
            make.top.mas_equalTo(self.pigTypeWeightLab.mas_top);
            make.width.mas_equalTo(89);
            make.height.mas_equalTo(16);
        }];
        
    }
}


#pragma mark - setter methods

/*
 @property (nonatomic, strong) NSNumber *unitPrice;
 @property (nonatomic, strong) NSNumber *advanceSaleId;
 @property (nonatomic, copy) NSString *aliasName;
 @property (nonatomic, copy) NSString *headImg;
 @property (nonatomic, copy) NSString *totalPrice;
 @property (nonatomic, strong) NSNumber *weight;
 @property (nonatomic, copy) NSString *oldPrice;
 @property (nonatomic, copy) NSString *chunksName;
 @property (nonatomic, strong) NSNumber *advancesaleType;  //类型:0仓库1预留;2一键发单;3摇一摇;4上架5赠送
 @property (nonatomic, strong) NSNumber *promotionIf;
 @property (nonatomic, strong) NSNumber *pigId;
 @property (nonatomic, strong) NSNumber *shopId;
 @property (nonatomic, strong) NSNumber *meatChunksId;
 
 @property (nonatomic, strong) NSNumber *divisionPlanId;
 @property (nonatomic, strong) NSNumber *pigPositionId;
 @property (nonatomic, copy) NSString *remark;
 

 */

- (void)setItem:(ShopSeparateList *)item
{
//    self.pigTypeTipLab.text = @"五花肉";
//    self.pigTypeNOLab.text = @"HT-02";
//    self.pigTypeWeightLab.text = @"重量10kg";
//    self.pigTypePriceSignalLab.text = @"单价12元/500g";
//    NSMutableAttributedString *aims = [@"¥172.8" createDeleteStringByTextColor:UIColorFromRGB(0x999999) font:mFont(12)];
//    self.pigTypePriceCancelLab.attributedText = aims;
//    self.pigTypePriceLab.text = @"¥216";
    
    
    self.pigTypeTipLab.text = item.chunksName;
    [self.shopIcon sd_setImageWithURL:[NSURL URLWithString:item.headImg] placeholderImage:[UIImage imageNamed:@"placeholder_small"]];
    self.pigTypeNOLab.text = item.aliasName;
    self.pigTypeWeightLab.text = [NSString stringWithFormat:@"重量%@kg", item.weight];
    self.pigTypePriceSignalLab.text = [NSString stringWithFormat:@"单价%@元/500g", item.unitPrice];
    NSString *price = [NSString stringWithFormat:@"¥%@", item.totalPrice];
    NSMutableAttributedString *aims = [price createDeleteStringByTextColor:UIColorFromRGB(0x999999) font:mFont(12)];
    self.pigTypePriceCancelLab.attributedText = aims;
    self.pigTypePriceLab.text = @"¥216";

    
    
    
    
}


#pragma mark - getter methods

- (UIImageView *)shopIcon{
    if (!_shopIcon) {
        _shopIcon = [[UIImageView alloc] init];
        [self addShadowAndCircleCorner:_shopIcon.layer corner:5];
        _shopIcon.image = [UIImage imageNamed:@"placeholder_small"];
    }
    return _shopIcon;
}


- (UILabel *)pigTypeTipLab{
    
    if (! _pigTypeTipLab){
        _pigTypeTipLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x262626) font:mFont(16) textAliment:0];
    }
    return _pigTypeTipLab;
}


- (UILabel *)pigTypeNOLab{
    
    if (!_pigTypeNOLab){
        _pigTypeNOLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x333333) font:mFont(15) textAliment:0];
    }
    return _pigTypeNOLab;
}


- (UILabel *)pigTypePriceLab{
    
    if (!_pigTypePriceLab){
        _pigTypePriceLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0xF25C62) font:mFont(17) textAliment:0];
    }
    return _pigTypePriceLab;
}


- (UILabel *)pigTypePriceCancelLab{
    
    if (!_pigTypePriceCancelLab){
        _pigTypePriceCancelLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x999999) font:mFont(12) textAliment:0];
    }
    return _pigTypePriceCancelLab;
}


- (UILabel *)pigTypeWeightLab {
    
    if (!_pigTypeWeightLab){
        _pigTypeWeightLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x9C9C9C) font:mFont(10) textAliment:1];
        _pigTypeWeightLab.backgroundColor = UIColorFromRGB(0xF2F4F7);
        [self addShadowAndCircleCorner:_pigTypeWeightLab.layer corner:9];
    }
    return _pigTypeWeightLab;
}


- (UILabel *)pigTypePriceSignalLab{
    
    if (!_pigTypePriceSignalLab){
        _pigTypePriceSignalLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x9C9C9C) font:mFont(10) textAliment:1];
        _pigTypePriceSignalLab.backgroundColor = UIColorFromRGB(0xF2F4F7);
        [self addShadowAndCircleCorner:_pigTypePriceSignalLab.layer corner:9];
    }
    return _pigTypePriceSignalLab;
}




@end
